/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package 编辑器.tabpane有关闭按钮;

import java.awt.Component; 
import javax.swing.Icon;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import 编辑器.tabpane有关闭按钮.TabPanel标题;

/**
 *
 * @author yanxi
 */
public class JTabbedPane带关闭按钮 extends JTabbedPane {
    
    public JTabbedPane带关闭按钮(){ 
        this.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                for(int i=0;i<JTabbedPane带关闭按钮.this.getTabCount();i++){ 
                    TabPanel标题 tp=(TabPanel标题)JTabbedPane带关闭按钮.this.getTabComponentAt(i);  
                    if(tp!=null){
                        tp.jRadioButton关闭.setSelected(JTabbedPane带关闭按钮.this.getSelectedIndex()==i); 
                    }
                }
            }
        }); 
    }
    
    public void 设置或更新UI(){ 
        for(int i=0;i<this.getTabCount();i++){
            TabPanel标题 tp=(TabPanel标题)this.getTabComponentAt(i);
            //tp.设置或更新UI();
        }
    }

    @Override
    public void addTab(String title, Component component) {
        addTab(title, null, component,""); 
    }

    @Override
    public void addTab(String title, Icon icon, Component component) {
        addTab(title, icon, component,""); 
    }

    @Override
    public void addTab(String title, Icon icon, Component component, String tip) {
        super.addTab(title, icon, component, tip);
        TabPanel标题 tp=new TabPanel标题(title, this);
        this.setTabComponentAt(this.getTabCount()-1, tp);
        tp.jRadioButton关闭.setSelected(true);
    }

}
